
const { apiPreFix } = require('../config').server
const userController = require('../controllers/user')
const rp = require('request-promise')
module.exports = (router) => {
  /**
   * 注册验证码
   */
  router.post(`${apiPreFix}/wwj/callback`, async ctx => {
    console.log('/wwj/callback', ctx.request.body)
    let options = {
        method: 'POST',
        json: true,
        uri: 'http://items.ufunet.cn/api/api?ifname=ifs.wwj.callback',
        body: ctx.request.body
    }
    await rp(options).then(data => {
      console.log(data)
    }).catch(err => {
       
    })
    ctx.body = ctx.request.body
  })
  /**
   * 注册验证码
   */
  router.post(`${apiPreFix}/user/signCode`, async  ctx => {
    await userController.signCode(ctx)
  })
  /**
   * 注册
   */
  router.post(`${apiPreFix}/user/signUp`, async  ctx => {
    await userController.signUp(ctx)
  })
  /**
   * 登录
   */
  router.post(`${apiPreFix}/user/login`, async  ctx => {
    await userController.login(ctx)
  })
}